home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Tcl / configure.in next >
Encoding:
Text File  |  1996-07-16  |  29.2 KB  |  961 lines

  1. dnl    This file is an input file used by the GNU "autoconf" program to
  2. dnl    generate the file "configure", which is run during Tcl installation
  3. dnl    to configure the system for the local environment.
  4. AC_INIT(./tcl.h)
  5. # SCCS: @(#) configure.in 1.102 96/04/17 10:46:25
  6.  
  7. TCL_VERSION=7.5
  8. TCL_MAJOR_VERSION=7
  9. TCL_MINOR_VERSION=5
  10. VERSION=${TCL_VERSION}
  11.  
  12. if test "${prefix}" = "NONE"; then
  13.     prefix=/usr/local
  14. fi
  15. if test "${exec_prefix}" = "NONE"; then
  16.     exec_prefix=$prefix
  17. fi
  18.  
  19. AC_PROG_RANLIB
  20. AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available],
  21.     [tcl_ok=$enableval], [tcl_ok=no])
  22. if test "$tcl_ok" = "yes"; then
  23.     AC_PROG_CC
  24. else
  25.     CC=${CC-cc}
  26. AC_SUBST(CC)
  27. fi
  28. AC_C_CROSS
  29.  
  30. #--------------------------------------------------------------------
  31. #    Supply substitutes for missing POSIX library procedures, or
  32. #    set flags so Tcl uses alternate procedures.
  33. #--------------------------------------------------------------------
  34.  
  35. AC_REPLACE_FUNCS(getcwd opendir strerror strstr)
  36. AC_REPLACE_FUNCS(strtol tmpnam waitpid)
  37. AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR))
  38. AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD))
  39. AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3))
  40. AC_CHECK_FUNC(uname, , AC_DEFINE(NO_UNAME))
  41.  
  42. #--------------------------------------------------------------------
  43. #    On a few very rare systems, all of the libm.a stuff is
  44. #    already in libc.a.  Set compiler flags accordingly.
  45. #    Also, Linux requires the "ieee" library for math to work
  46. #    right (and it must appear before "-lm").
  47. #--------------------------------------------------------------------
  48.  
  49. AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
  50. AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
  51.  
  52. #--------------------------------------------------------------------
  53. #    Supply substitutes for missing POSIX header files.  Special
  54. #    notes:
  55. #        - stdlib.h doesn't define strtol, strtoul, or
  56. #          strtod insome versions of SunOS
  57. #        - some versions of string.h don't declare procedures such
  58. #          as strstr
  59. #--------------------------------------------------------------------
  60.  
  61. AC_MSG_CHECKING(dirent.h)
  62. AC_TRY_LINK([#include <sys/types.h>
  63. #include <dirent.h>], [
  64. #ifndef _POSIX_SOURCE
  65. #   ifdef __Lynx__
  66.     /*
  67.      * Generate compilation error to make the test fail:  Lynx headers
  68.      * are only valid if really in the POSIX environment.
  69.      */
  70.  
  71.     missing_procedure();
  72. #   endif
  73. #endif
  74. DIR *d;
  75. struct dirent *entryPtr;
  76. char *p;
  77. d = opendir("foobar");
  78. entryPtr = readdir(d);
  79. p = entryPtr->d_name;
  80. closedir(d);
  81. ], tcl_ok=yes, tcl_ok=no)
  82. if test $tcl_ok = no; then
  83.     AC_DEFINE(NO_DIRENT_H)
  84. fi
  85. AC_MSG_RESULT($tcl_ok)
  86. AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
  87. AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
  88. AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
  89. AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
  90. AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
  91. AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
  92. AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
  93. if test $tcl_ok = 0; then
  94.     AC_DEFINE(NO_STDLIB_H)
  95. fi
  96. AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
  97. AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
  98. AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
  99. if test $tcl_ok = 0; then
  100.     AC_DEFINE(NO_STRING_H)
  101. fi
  102. AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
  103. AC_HAVE_HEADERS(unistd.h)
  104.  
  105. #--------------------------------------------------------------------
  106. #    Include sys/select.h if it exists and if it supplies things
  107. #    that appear to be useful and aren't already in sys/types.h.
  108. #    This appears to be true only on the RS/6000 under AIX.  Some
  109. #    systems like OSF/1 have a sys/select.h that's of no use, and
  110. #    other systems like SCO UNIX have a sys/select.h that's
  111. #    pernicious.  If "fd_set" isn't defined anywhere then set a
  112. #    special flag.
  113. #--------------------------------------------------------------------
  114.  
  115. AC_MSG_CHECKING([fd_set and sys/select])
  116. AC_TRY_COMPILE([#include <sys/types.h>],
  117.     [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
  118. if test $tk_ok = no; then
  119.     AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
  120.     if test $tk_ok = yes; then
  121.     AC_DEFINE(HAVE_SYS_SELECT_H)
  122.     fi
  123. fi
  124. AC_MSG_RESULT($tk_ok)
  125. if test $tk_ok = no; then
  126.     AC_DEFINE(NO_FD_SET)
  127. fi
  128.  
  129. #------------------------------------------------------------------------------
  130. #       Find out all about time handling differences.
  131. #------------------------------------------------------------------------------
  132.  
  133. AC_CHECK_HEADERS(sys/time.h)
  134. AC_HEADER_TIME
  135. AC_STRUCT_TIMEZONE
  136.  
  137. AC_MSG_CHECKING([tm_tzadj in struct tm])
  138. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
  139.         [AC_DEFINE(HAVE_TM_TZADJ)
  140.          AC_MSG_RESULT(yes)],
  141.         AC_MSG_RESULT(no))
  142.  
  143. AC_MSG_CHECKING([tm_gmtoff in struct tm])
  144. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
  145.         [AC_DEFINE(HAVE_TM_GMTOFF)
  146.          AC_MSG_RESULT(yes)],
  147.         AC_MSG_RESULT(no))
  148.  
  149. #
  150. # Its important to include time.h in this check, as some systems (like convex)
  151. # have timezone functions, etc.
  152. #
  153. AC_MSG_CHECKING([timezone variable])
  154. AC_TRY_COMPILE([#include <time.h>],
  155.         [extern long timezone;
  156.          timezone += 1;
  157.          exit (0);],
  158.         [AC_DEFINE(HAVE_TIMEZONE_VAR)
  159.          AC_MSG_RESULT(yes)],
  160.         AC_MSG_RESULT(no))
  161.  
  162. #--------------------------------------------------------------------
  163. #    On some systems strstr is broken: it returns a pointer even
  164. #    even if the original string is empty.
  165. #--------------------------------------------------------------------
  166.  
  167. AC_MSG_CHECKING([proper strstr implementation])
  168. AC_TRY_RUN([
  169. extern int strstr();
  170. int main()
  171. {
  172.     exit(strstr("\0test", "test") ? 1 : 0);
  173. }
  174. ], tcl_ok=yes, tcl_ok=no, tcl_ok=no)
  175. if test $tcl_ok = yes; then
  176.     AC_MSG_RESULT(yes)
  177. else
  178.     AC_MSG_RESULT([broken, using substitute])
  179.     LIBOBJS="$LIBOBJS strstr.o"
  180. fi
  181.  
  182. #--------------------------------------------------------------------
  183. #    Check for strtoul function.  This is tricky because under some
  184. #    versions of AIX strtoul returns an incorrect terminator
  185. #    pointer for the string "0".
  186. #--------------------------------------------------------------------
  187.  
  188. AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
  189. AC_TRY_RUN([
  190. extern int strtoul();
  191. int main()
  192. {
  193.     char *string = "0";
  194.     char *term;
  195.     int value;
  196.     value = strtoul(string, &term, 0);
  197.     if ((value != 0) || (term != (string+1))) {
  198.         exit(1);
  199.     }
  200.     exit(0);
  201. }], , tcl_ok=0, tcl_ok=0)
  202. if test "$tcl_ok" = 0; then
  203.     test -n "$verbose" && echo "    Adding strtoul.o."
  204.     LIBOBJS="$LIBOBJS strtoul.o"
  205. fi
  206.  
  207. #--------------------------------------------------------------------
  208. #    Check for the strtod function.  This is tricky because in some
  209. #    versions of Linux strtod mis-parses strings starting with "+".
  210. #--------------------------------------------------------------------
  211.  
  212. AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
  213. AC_TRY_RUN([
  214. extern double strtod();
  215. int main()
  216. {
  217.     char *string = " +69";
  218.     char *term;
  219.     double value;
  220.     value = strtod(string, &term);
  221.     if ((value != 69) || (term != (string+4))) {
  222.     exit(1);
  223.     }
  224.     exit(0);
  225. }], , tcl_ok=0, tcl_ok=0)
  226. if test "$tcl_ok" = 0; then
  227.     test -n "$verbose" && echo "    Adding strtod.o."
  228.     LIBOBJS="$LIBOBJS strtod.o"
  229. fi
  230.  
  231. #--------------------------------------------------------------------
  232. #    Under Solaris 2.4, strtod returns the wrong value for the
  233. #    terminating character under some conditions.  Check for this
  234. #    and if the problem exists use a substitute procedure
  235. #    "fixstrtod" that corrects the error.
  236. #--------------------------------------------------------------------
  237.  
  238. AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
  239. if test "$tcl_strtod" = 1; then
  240.     AC_MSG_CHECKING([for Solaris strtod bug])
  241.     AC_TRY_RUN([
  242.     extern double strtod();
  243.     int main()
  244.     {
  245.         char *string = "NaN";
  246.         char *term;
  247.         strtod(string, &term);
  248.         if ((term != string) && (term[-1] == 0)) {
  249.         exit(1);
  250.         }
  251.         exit(0);
  252.     }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
  253.     if test $tcl_ok = 1; then
  254.     AC_MSG_RESULT(ok)
  255.     else
  256.     AC_MSG_RESULT(buggy)
  257.     LIBOBJS="$LIBOBJS fixstrtod.o"
  258.     AC_DEFINE(strtod, fixstrtod)
  259.     fi
  260. fi
  261.  
  262. #--------------------------------------------------------------------
  263. #    Check for various typedefs and provide substitutes if
  264. #    they don't exist.
  265. #--------------------------------------------------------------------
  266.  
  267. AC_TYPE_MODE_T
  268. AC_TYPE_PID_T
  269. AC_TYPE_SIZE_T
  270. AC_TYPE_UID_T
  271.  
  272. #--------------------------------------------------------------------
  273. #    If a system doesn't have an opendir function (man, that's old!)
  274. #    then we have to supply a different version of dirent.h which
  275. #    is compatible with the substitute version of opendir that's
  276. #    provided.  This version only works with V7-style directories.
  277. #--------------------------------------------------------------------
  278.  
  279. AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
  280.  
  281. #--------------------------------------------------------------------
  282. #    Check for the existence of sys_errlist (this is only needed if
  283. #    there's no strerror, but I don't know how to conditionalize the
  284. #    check).
  285. #--------------------------------------------------------------------
  286.  
  287. AC_MSG_CHECKING(sys_errlist)
  288. AC_TRY_LINK(, [
  289. extern char *sys_errlist[];
  290. extern int sys_nerr;
  291. sys_errlist[sys_nerr-1][0] = 0;
  292. ], tcl_ok=yes, tcl_ok=no)
  293. AC_MSG_RESULT($tcl_ok)
  294. if test $tcl_ok = no; then
  295.     AC_DEFINE(NO_SYS_ERRLIST)
  296. fi
  297.  
  298. #--------------------------------------------------------------------
  299. #    The check below checks whether <sys/wait.h> defines the type
  300. #    "union wait" correctly.  It's needed because of weirdness in
  301. #    HP-UX where "union wait" is defined in both the BSD and SYS-V
  302. #    environments.  Checking the usability of WIFEXITED seems to do
  303. #    the trick.
  304. #--------------------------------------------------------------------
  305.  
  306. AC_MSG_CHECKING([union wait])
  307. AC_TRY_LINK([#include <sys/types.h> 
  308. #include <sys/wait.h>], [
  309. union wait x;
  310. WIFEXITED(x);        /* Generates compiler error if WIFEXITED
  311.              * uses an int. */
  312. ], tcl_ok=yes, tcl_ok=no)
  313. AC_MSG_RESULT($tcl_ok)
  314. if test $tcl_ok = no; then
  315.     AC_DEFINE(NO_UNION_WAIT)
  316. fi
  317.  
  318. #--------------------------------------------------------------------
  319. #    Check to see whether the system supports the matherr function
  320. #    and its associated type "struct exception".
  321. #--------------------------------------------------------------------
  322.  
  323. AC_MSG_CHECKING([matherr support])
  324. AC_TRY_COMPILE([#include <math.h>], [
  325. struct exception x;
  326. x.type = DOMAIN;
  327. x.type = SING;
  328. ], tcl_ok=yes, tcl_ok=no)
  329. AC_MSG_RESULT($tcl_ok)
  330. if test $tcl_ok = yes; then
  331.     AC_DEFINE(NEED_MATHERR)
  332. fi
  333.  
  334. #--------------------------------------------------------------------
  335. #    Check to see whether the system provides a vfork kernel call.
  336. #    If not, then use fork instead.  Also, check for a problem with
  337. #    vforks and signals that can cause core dumps if a vforked child
  338. #    resets a signal handler.  If the problem exists, then use fork
  339. #    instead of vfork.
  340. #--------------------------------------------------------------------
  341.  
  342. AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
  343. if test "$tcl_ok" = 1; then
  344.     AC_MSG_CHECKING([vfork/signal bug]);
  345.     AC_TRY_RUN([
  346.     #include <stdio.h>
  347.     #include <signal.h>
  348.     #include <sys/wait.h>
  349.     int gotSignal = 0;
  350.     sigProc(sig)
  351.         int sig;
  352.     {
  353.         gotSignal = 1;
  354.     }
  355.     main()
  356.     {
  357.         int pid, sts;
  358.         (void) signal(SIGCHLD, sigProc);
  359.         pid = vfork();
  360.         if (pid <  0) {
  361.         exit(1);
  362.         } else if (pid == 0) {
  363.         (void) signal(SIGCHLD, SIG_DFL);
  364.         _exit(0);
  365.         } else {
  366.         (void) wait(&sts);
  367.         }
  368.         exit((gotSignal) ? 0 : 1);
  369.     }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
  370.     if test "$tcl_ok" = 1; then
  371.     AC_MSG_RESULT(ok)
  372.     else
  373.     AC_MSG_RESULT([buggy, using fork instead])
  374.     fi
  375. fi
  376. rm -f core
  377. if test "$tcl_ok" = 0; then
  378.     AC_DEFINE(vfork, fork)
  379. fi
  380.  
  381. #--------------------------------------------------------------------
  382. #    Check whether there is an strncasecmp function on this system.
  383. #    This is a bit tricky because under SCO it's in -lsocket and
  384. #    under Sequent Dynix it's in -linet.
  385. #--------------------------------------------------------------------
  386.  
  387. AC_CHECK_FUNC(strncasecmp, tcl_ok=1, tcl_ok=0)
  388. if test "$tcl_ok" = 0; then
  389.     AC_CHECK_LIB(socket, strncasecmp, tcl_ok=1, tcl_ok=0)
  390. fi
  391. if test "$tcl_ok" = 0; then
  392.     AC_CHECK_LIB(inet, strncasecmp, tcl_ok=1, tcl_ok=0)
  393. fi
  394. if test "$tcl_ok" = 0; then
  395.     LIBOBJS="$LIBOBJS strncasecmp.o"
  396. fi
  397.  
  398. #--------------------------------------------------------------------
  399. #    The code below deals with several issues related to gettimeofday:
  400. #    1. Some systems don't provide a gettimeofday function at all
  401. #       (set NO_GETTOD if this is the case).
  402. #    2. SGI systems don't use the BSD form of the gettimeofday function,
  403. #       but they have a BSDgettimeofday function that can be used instead.
  404. #    3. See if gettimeofday is declared in the <sys/time.h> header file.
  405. #       if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
  406. #       declare it.
  407. #--------------------------------------------------------------------
  408.  
  409. AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY),
  410.     AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)))
  411. AC_MSG_CHECKING([for gettimeofday declaration])
  412. AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
  413.     AC_MSG_RESULT(missing)
  414.     AC_DEFINE(GETTOD_NOT_DECLARED)
  415. ])
  416.  
  417. #--------------------------------------------------------------------
  418. #    Interactive UNIX requires -linet instead of -lsocket, plus it
  419. #    needs net/errno.h to define the socket-related error codes.
  420. #--------------------------------------------------------------------
  421.  
  422. AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
  423. AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
  424.  
  425. #--------------------------------------------------------------------
  426. #    Check for the existence of the -lsocket and -lnsl libraries.
  427. #    The order here is important, so that they end up in the right
  428. #    order in the command line generated by make.  Here are some
  429. #    special considerations:
  430. #    1. Use "connect" and "accept" to check for -lsocket, and
  431. #       "gethostbyname" to check for -lnsl.
  432. #    2. Use each function name only once:  can't redo a check because
  433. #       autoconf caches the results of the last check and won't redo it.
  434. #    3. Use -lnsl and -lsocket only if they supply procedures that
  435. #       aren't already present in the normal libraries.  This is because
  436. #       IRIX 5.2 has libraries, but they aren't needed and they're
  437. #       bogus:  they goof up name resolution if used.
  438. #    4. On some SVR4 systems, can't use -lsocket without -lnsl too.
  439. #       To get around this problem, check for both libraries together
  440. #       if -lsocket doesn't work by itself.
  441. #--------------------------------------------------------------------
  442.  
  443. tcl_checkBoth=0
  444. AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
  445. if test "$tcl_checkSocket" = 1; then
  446.     AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
  447. fi
  448. if test "$tcl_checkBoth" = 1; then
  449.     tk_oldLibs=$LIBS
  450.     LIBS="$LIBS -lsocket -lnsl"
  451.     AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
  452. fi
  453. AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
  454.  
  455. #--------------------------------------------------------------------
  456. #    The statements below define a collection of symbols related to
  457. #    dynamic loading and shared libraries:
  458. #
  459. #    DL_OBJS -    Name of the object file that implements dynamic
  460. #            loading for Tcl on this system.
  461. #    DL_LIBS -    Library file(s) to include in tclsh and other base
  462. #            applications in order for the "load" command to work.
  463. #    LD_FLAGS -    Flags to pass to the compiler when linking object
  464. #            files into an executable application binary such
  465. #            as tclsh.
  466. #    LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
  467. #            that tell the run-time dynamic linker where to look
  468. #            for shared libraries such as libtcl.so.  Depends on
  469. #            the variable LIB_INSTALL_DIR in the Makefile.
  470. #    MAKE_LIB -    Command to execute to build the Tcl library;
  471. #            differs depending on whether or not Tcl is being
  472. #            compiled as a shared library.
  473. #    SHLIB_CFLAGS -    Flags to pass to cc when compiling the components
  474. #            of a shared library (may request position-independent
  475. #            code, among other things).
  476. #    SHLIB_LD -    Base command to use for combining object files
  477. #            into a shared library.
  478. #    SHLIB_LD_LIBS -    Dependent libraries for the linker to scan when
  479. #            creating shared libraries.  This symbol typically
  480. #            goes at the end of the "ld" commands that build
  481. #            shared libraries. The value of the symbol is
  482. #            "${LIBS}" if all of the dependent libraries should
  483. #            be specified when creating a shared library.  If
  484. #            dependent libraries should not be specified (as on
  485. #            SunOS 4.x, where they cause the link to fail, or in
  486. #            general if Tcl and Tk aren't themselves shared
  487. #            libraries), then this symbol has an empty string
  488. #            as its value.
  489. #    SHLIB_SUFFIX -    Suffix to use for the names of dynamically loadable
  490. #            extensions.  An empty string means we don't know how
  491. #            to use shared libraries on this platform.
  492. #    TCL_LIB_FILE -    Name of the file that contains the Tcl library, such
  493. #            as libtcl7.5.so or libtcl7.5.a.
  494. #    TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
  495. #            in the shared library name, using the $VERSION variable
  496. #            to put the version in the right place.  This is used
  497. #            by platforms that need non-standard library names.
  498. #            Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
  499. #            to have a version after the .so, and ${VERSION}.a
  500. #            on AIX, since the Tcl shared library needs to have
  501. #            a .a extension whereas shared objects for loadable
  502. #            extensions have a .so extension.  Defaults to
  503. #            ${VERSION}${SHLIB_SUFFIX}.
  504. #--------------------------------------------------------------------
  505.  
  506. # Step 1: set the variable "system" to hold the name and version number
  507. # for the system.  This can usually be done via the "uname" command, but
  508. # there are a few systems, like Next, where this doesn't work.
  509.  
  510. AC_MSG_CHECKING([system version (for dynamic loading)])
  511. if test -f /usr/lib/NextStep/software_version; then
  512.     system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  513. else
  514.     system=`uname -s`-`uname -r`
  515.     if test "$?" -ne 0 ; then
  516.     AC_MSG_RESULT([unknown (can't find uname command)])
  517.     system=unknown
  518.     else
  519.     # Special check for weird MP-RAS system (uname returns weird
  520.     # results, and the version is kept in special file).
  521.     
  522.     if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  523.         system=MP-RAS-`awk '{print $3}' /etc/.relid'`
  524.     fi
  525.     if test "`uname -s`" = "AIX" ; then
  526.         system=AIX-`uname -v`.`uname -r`
  527.     fi
  528.     AC_MSG_RESULT($system)
  529.     fi
  530. fi
  531.  
  532. # Step 2: check for existence of -ldl library.  This is needed because
  533. # Linux can use either -ldl or -ldld for dynamic loading.
  534.  
  535. AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
  536.  
  537. # Step 3: disable dynamic loading if requested via a command-line switch.
  538.  
  539. AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
  540.     [tcl_ok=$enableval], [tcl_ok=yes])
  541. if test "$tcl_ok" = "no"; then
  542.     system=unknown
  543. fi
  544.  
  545. # Step 4: set configuration options based on system name and version.
  546.  
  547. fullSrcDir=`cd $srcdir; pwd`
  548. AIX=no
  549. TCL_SHARED_LIB_SUFFIX=""
  550. TCL_UNSHARED_LIB_SUFFIX=""
  551. TCL_LIB_VERSIONS_OK=ok
  552. case $system in
  553.     AIX-*)
  554.     SHLIB_CFLAGS=""
  555.     SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512"
  556.     SHLIB_LD_LIBS='${LIBS}'
  557.     SHLIB_SUFFIX=".so"
  558.     DL_OBJS="tclLoadDl.o tclLoadAix.o"
  559.     DL_LIBS="-lld"
  560.     LD_FLAGS=""
  561.     LD_SEARCH_FLAGS='-L${LIB_INSTALL_DIR}'
  562.     AC_DEFINE(NO_DLFCN_H)
  563.     AIX=yes
  564.     TCL_SHARED_LIB_SUFFIX='${VERSION}.a'
  565.     ;;
  566.     HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  567.     SHLIB_CFLAGS="+z"
  568.     SHLIB_LD="ld -b"
  569.     SHLIB_LD_LIBS='${LIBS}'
  570.     SHLIB_SUFFIX=".sl"
  571.     DL_OBJS="tclLoadShl.o"
  572.     DL_LIBS="-ldld"
  573.     LD_FLAGS="-Wl,-E"
  574.     LD_SEARCH_FLAGS='-Wl,+b,${LIB_INSTALL_DIR}:.'
  575.     ;;
  576.     IRIX-4.*)
  577.     SHLIB_CFLAGS="-G 0"
  578.     SHLIB_SUFFIX="..o"
  579.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  580.     SHLIB_LD_LIBS=""
  581.     DL_OBJS="tclLoadAout.o"
  582.     DL_LIBS=""
  583.     LD_FLAGS="-Wl,-D,08000000"
  584.     LD_SEARCH_FLAGS=""
  585.     ;;
  586.     IRIX-5.*)
  587.     SHLIB_CFLAGS=""
  588.     SHLIB_LD="ld -shared -rdata_shared"
  589.     SHLIB_LD_LIBS=""
  590.     SHLIB_SUFFIX=".so"
  591.     DL_OBJS="tclLoadDl.o"
  592.     DL_LIBS=""
  593.     LD_FLAGS=""
  594.     LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_INSTALL_DIR}'
  595.     ;;
  596.     Linux*)
  597.     SHLIB_CFLAGS="-fPIC"
  598.     SHLIB_LD_LIBS=""
  599.     SHLIB_SUFFIX=".so"
  600.     if test "$have_dl" = yes; then
  601.         SHLIB_LD="${CC} -shared"
  602.         DL_OBJS="tclLoadDl.o"
  603.         DL_LIBS="-ldl"
  604.         LD_FLAGS="-rdynamic"
  605.         LD_SEARCH_FLAGS=""
  606.     else
  607.         AC_CHECK_HEADER(dld.h, [
  608.         SHLIB_LD="ld -shared"
  609.         DL_OBJS="tclLoadDld.o"
  610.         DL_LIBS="-ldld"
  611.         LD_FLAGS=""
  612.         LD_SEARCH_FLAGS=""])
  613.     fi
  614.     ;;
  615.     MP-RAS-02*)
  616.     SHLIB_CFLAGS="-K PIC"
  617.     SHLIB_LD="cc -G"
  618.     SHLIB_LD_LIBS=""
  619.     SHLIB_SUFFIX=".so"
  620.     DL_OBJS="tclLoadDl.o"
  621.     DL_LIBS="-ldl"
  622.     LD_FLAGS=""
  623.     LD_SEARCH_FLAGS=""
  624.     ;;
  625.     MP-RAS-*)
  626.     SHLIB_CFLAGS="-K PIC"
  627.     SHLIB_LD="cc -G"
  628.     SHLIB_LD_LIBS=""
  629.     SHLIB_SUFFIX=".so"
  630.     DL_OBJS="tclLoadDl.o"
  631.     DL_LIBS="-ldl"
  632.     LD_FLAGS="-Wl,-Bexport"
  633.     LD_SEARCH_FLAGS=""
  634.     ;;
  635.     NetBSD-*|FreeBSD-*)
  636.     # Not available on all versions:  check for include file.
  637.     AC_CHECK_HEADER(dlfcn.h, [
  638.         SHLIB_CFLAGS="-fpic"
  639.         SHLIB_LD="ld -Bshareable"
  640.         SHLIB_LD_LIBS=""
  641.         SHLIB_SUFFIX=".so"
  642.         DL_OBJS="tclLoadDl2.o"
  643.         DL_LIBS=""
  644.         LD_FLAGS=""
  645.         LD_SEARCH_FLAGS=""
  646.     ], [
  647.         SHLIB_CFLAGS=""
  648.         SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  649.         SHLIB_LD_LIBS=""
  650.         SHLIB_SUFFIX="..o"
  651.         DL_OBJS="tclLoadAout.o"
  652.         DL_LIBS=""
  653.         LD_FLAGS=""
  654.         LD_SEARCH_FLAGS=""
  655.     ])
  656.  
  657.     # FreeBSD doesn't handle version numbers with dots.  Also, have to
  658.     # append a dummy version number to .so file names.
  659.  
  660.     TCL_SHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.so.1.0'
  661.     TCL_UNSHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.a'
  662.     TCL_LIB_VERSIONS_OK=nodots
  663.     ;;
  664.     NEXTSTEP-*)
  665.     SHLIB_CFLAGS=""
  666.     SHLIB_LD="cc -nostdlib -r"
  667.     SHLIB_LD_LIBS=""
  668.     SHLIB_SUFFIX=".so"
  669.     DL_OBJS="tclLoadNext.o"
  670.     DL_LIBS=""
  671.     LD_FLAGS=""
  672.     LD_SEARCH_FLAGS=""
  673.     ;;
  674.     OSF1-1.[012])
  675.     # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
  676.     SHLIB_CFLAGS=""
  677.     # Hack: make package name same as library name
  678.     SHLIB_LD='ld -R -export $@:'
  679.     SHLIB_LD_LIBS=""
  680.     SHLIB_SUFFIX=".so"
  681.     DL_OBJS="tclLoadOSF.o"
  682.     DL_LIBS=""
  683.     LD_FLAGS=""
  684.     LD_SEARCH_FLAGS=""
  685.     ;;
  686.     OSF1-1.*)
  687.     # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
  688.     SHLIB_CFLAGS="-fpic"
  689.     SHLIB_LD="ld -shared"
  690.     SHLIB_LD_LIBS=""
  691.     SHLIB_SUFFIX=".so"
  692.     DL_OBJS="tclLoadDl.o"
  693.     DL_LIBS=""
  694.     LD_FLAGS=""
  695.     LD_SEARCH_FLAGS=""
  696.     ;;
  697.     OSF1-V*)
  698.         # Digital OSF/1
  699.     SHLIB_CFLAGS=""
  700.     SHLIB_LD='ld -shared -expect_unresolved "*"'
  701.     SHLIB_LD_LIBS=""
  702.     SHLIB_SUFFIX=".so"
  703.     DL_OBJS="tclLoadDl.o"
  704.     DL_LIBS=""
  705.     LD_FLAGS=""
  706.     LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_INSTALL_DIR}'
  707.     ;;
  708.     RISCos-*)
  709.     SHLIB_CFLAGS="-G 0"
  710.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  711.     SHLIB_LD_LIBS=""
  712.     SHLIB_SUFFIX="..o"
  713.     DL_OBJS="tclLoadAout.o"
  714.     DL_LIBS=""
  715.     LD_FLAGS="-Wl,-D,08000000"
  716.     LD_SEARCH_FLAGS=""
  717.     ;;
  718.     SCO_SV-3.2*)
  719.         # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
  720.         # this test works, since "uname -s" was non-standard in 3.2.4 and
  721.         # below.
  722.     SHLIB_CFLAGS="-Kpic -belf"
  723.     SHLIB_LD="ld -G"
  724.     SHLIB_LD_LIBS=""
  725.     SHLIB_SUFFIX=".so"
  726.     DL_OBJS="tclLoadDl.o"
  727.     DL_LIBS=""
  728.     LD_FLAGS="-belf -Wl,-Bexport"
  729.     LD_SEARCH_FLAGS=""
  730.     ;;
  731.      SINIX*5.4*)
  732.     SHLIB_CFLAGS="-K PIC"
  733.     SHLIB_LD="cc -G"
  734.     SHLIB_LD_LIBS=""
  735.     SHLIB_SUFFIX=".so"
  736.     DL_OBJS="tclLoadDl.o"
  737.     DL_LIBS="-ldl"
  738.     LD_FLAGS=""
  739.     LD_SEARCH_FLAGS=""
  740.     ;;
  741.     SunOS-4*)
  742.     SHLIB_CFLAGS="-PIC"
  743.     SHLIB_LD="ld"
  744.     SHLIB_LD_LIBS=""
  745.     SHLIB_SUFFIX=".so"
  746.     DL_OBJS="tclLoadDl.o"
  747.     DL_LIBS="-ldl"
  748.     LD_FLAGS=""
  749.     LD_SEARCH_FLAGS='-L${LIB_INSTALL_DIR}'
  750.  
  751.     # SunOS can't handle version numbers with dots in them in library
  752.     # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
  753.     # requires an extra version number at the end of .so file names.
  754.     # So, the library has to have a name like libtcl75.so.1.0
  755.  
  756.     TCL_SHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.so.1.0'
  757.     TCL_UNSHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.a'
  758.     TCL_LIB_VERSIONS_OK=nodots
  759.     ;;
  760.     SunOS-5*)
  761.     SHLIB_CFLAGS="-K PIC"
  762.     SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  763.     SHLIB_LD_LIBS='${LIBS}'
  764.     SHLIB_SUFFIX=".so"
  765.     DL_OBJS="tclLoadDl.o"
  766.     DL_LIBS="-ldl"
  767.     LD_FLAGS=""
  768.     LD_SEARCH_FLAGS='-R ${LIB_INSTALL_DIR}'
  769.     ;;
  770.     ULTRIX-4.*)
  771.     SHLIB_CFLAGS="-G 0"
  772.     SHLIB_SUFFIX="..o"
  773.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  774.     SHLIB_LD_LIBS=""
  775.     DL_OBJS="tclLoadAout.o"
  776.     DL_LIBS=""
  777.     LD_FLAGS="-Wl,-D,08000000"
  778.     LD_SEARCH_FLAGS=""
  779.     ;;
  780.     UNIX_SV*)
  781.     SHLIB_CFLAGS="-K PIC"
  782.     SHLIB_LD="cc -G"
  783.     SHLIB_LD_LIBS=""
  784.     SHLIB_SUFFIX=".so"
  785.     DL_OBJS="tclLoadDl.o"
  786.     DL_LIBS="-ldl"
  787.     LD_FLAGS="-Wl,-Bexport"
  788.     LD_SEARCH_FLAGS=""
  789.     ;;
  790. esac
  791.  
  792. # If pseudo-static linking is in use (see K. B. Kenny, "Dynamic Loading for
  793. # Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop, New Orleans, LA,
  794. # Computerized Processes Unlimited, 1994), then we need to determine which
  795. # of several header files defines the a.out file format (a.out.h, sys/exec.h,
  796. # or sys/exec_aout.h).  At present, we support only a file format that
  797. # is more or less version-7-compatible.  In particular,
  798. #    - a.out files must begin with `struct exec'.
  799. #    - the N_TXTOFF on the `struct exec' must compute the seek address
  800. #      of the text segment
  801. #    - The `struct exec' must contain a_magic, a_text, a_data, a_bss
  802. #      and a_entry fields.
  803. # The following compilation should succeed if and only if either sys/exec.h
  804. # or a.out.h is usable for the purpose.
  805. #
  806. # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
  807. # `struct exec' includes a second header that contains information that
  808. # duplicates the v7 fields that are needed.
  809.  
  810. if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
  811.     AC_MSG_CHECKING(sys/exec.h)
  812.     AC_TRY_COMPILE([#include <sys/exec.h>],[
  813.     struct exec foo;
  814.     unsigned long seek;
  815.     int flag;
  816. #if defined(__mips) || defined(mips)
  817.     seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  818. #else
  819.     seek = N_TXTOFF (foo);
  820. #endif
  821.     flag = (foo.a_magic == OMAGIC);
  822.     return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  823. ], tcl_ok=usable, tcl_ok=unusable)
  824.     AC_MSG_RESULT($tcl_ok)
  825.     if test $tcl_ok = usable; then
  826.     AC_DEFINE(USE_SYS_EXEC_H)
  827.     else
  828.     AC_MSG_CHECKING(a.out.h)
  829.     AC_TRY_COMPILE([#include <a.out.h>],[
  830.         struct exec foo;
  831.         unsigned long seek;
  832.         int flag;
  833. #if defined(__mips) || defined(mips)
  834.         seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  835. #else
  836.         seek = N_TXTOFF (foo);
  837. #endif
  838.         flag = (foo.a_magic == OMAGIC);
  839.         return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  840.     ], tcl_ok=usable, tcl_ok=unusable)
  841.     AC_MSG_RESULT($tcl_ok)
  842.     if test $tcl_ok = usable; then
  843.         AC_DEFINE(USE_A_OUT_H)
  844.     else
  845.         AC_MSG_CHECKING(sys/exec_aout.h)
  846.         AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
  847.         struct exec foo;
  848.         unsigned long seek;
  849.         int flag;
  850. #if defined(__mips) || defined(mips)
  851.         seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  852. #else
  853.         seek = N_TXTOFF (foo);
  854. #endif
  855.         flag = (foo.a_midmag == OMAGIC);
  856.         return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  857.         ], tcl_ok=usable, tcl_ok=unusable)
  858.         AC_MSG_RESULT($tcl_ok)
  859.         if test $tcl_ok = usable; then
  860.         AC_DEFINE(USE_SYS_EXEC_AOUT_H)
  861.         else
  862.         DL_OBJS=""
  863.         fi
  864.     fi
  865.     fi
  866. fi
  867.  
  868. if test "x$DL_OBJS" != "x" ; then
  869.     BUILD_DLTEST="\$(DLTEST_TARGETS)"
  870. else
  871.     echo "Can't figure out how to do dynamic loading or shared libraries"
  872.     echo "on this system."
  873.     SHLIB_CFLAGS=""
  874.     SHLIB_LD=""
  875.     SHLIB_SUFFIX=""
  876.     DL_OBJS="tclLoadNone.o"
  877.     DL_LIBS=""
  878.     LD_FLAGS=""
  879.     LD_SEARCH_FLAGS=""
  880.     BUILD_DLTEST=""
  881. fi
  882.  
  883. # If we're running gcc, then change the C flags for compiling shared
  884. # libraries to the right flags for gcc, instead of those for the
  885. # standard manufacturer compiler.
  886.  
  887. if test "$DL_OBJS" != "tclLoadNone.o" ; then
  888.     if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  889.     SHLIB_CFLAGS="-fPIC"
  890.     fi
  891. fi
  892.  
  893. #--------------------------------------------------------------------
  894. #    The statements below define a collection of symbols related to
  895. #    building libtcl as a shared library instead of a static library.
  896. #--------------------------------------------------------------------
  897.  
  898. realRanlib=$RANLIB
  899. if test "$TCL_SHARED_LIB_SUFFIX" = "" ; then
  900.     TCL_SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}'
  901. fi
  902. if test "$TCL_UNSHARED_LIB_SUFFIX" = "" ; then
  903.     TCL_UNSHARED_LIB_SUFFIX='${VERSION}.a'
  904. fi
  905. AC_ARG_ENABLE(shared,
  906.     [  --enable-shared         build libtcl as a shared library],
  907.     [tcl_ok=$enableval], [tcl_ok=no])
  908. if test "$tcl_ok" = "yes" -a "${SHLIB_SUFFIX}" != "" \
  909.     -a "${DL_OBJS}" != "tclLoadAout.o" ; then
  910.     TCL_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
  911.     TCL_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
  912.     eval "TCL_LIB_FILE=libtcl${TCL_SHARED_LIB_SUFFIX}"
  913.     MAKE_LIB="\${SHLIB_LD} -o ${TCL_LIB_FILE} \${OBJS} ${SHLIB_LD_LIBS}"
  914.     RANLIB=":"
  915. else
  916.     if test "$AIX" = "no" ; then
  917.     SHLIB_LD_LIBS=""
  918.     fi
  919.     TCL_SHLIB_CFLAGS=""
  920.     TCL_LD_SEARCH_FLAGS=""
  921.     eval "TCL_LIB_FILE=libtcl${TCL_UNSHARED_LIB_SUFFIX}"
  922.     MAKE_LIB="ar cr ${TCL_LIB_FILE} \${OBJS}"
  923. fi
  924.  
  925. # Note:  in the following variable, it's important to use the absolute
  926. # path name of the Tcl directory rather than "..":  this is because
  927. # AIX remembers this path and will attempt to use it at run-time to look
  928. # up the Tcl library.
  929.  
  930. if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
  931.     TCL_BUILD_LIB_SPEC="-L`pwd` -ltcl${VERSION}"
  932.     TCL_LIB_SPEC="-L${exec_prefix}/lib -ltcl${VERSION}"
  933. else
  934.     TCL_BUILD_LIB_SPEC="-L`pwd` -ltcl`echo ${VERSION} | tr -d .`"
  935.     TCL_LIB_SPEC="-L${exec_prefix}/lib -ltcl`echo ${VERSION} | tr -d .`"
  936. fi
  937.  
  938. AC_SUBST(BUILD_DLTEST)
  939. AC_SUBST(DL_LIBS)
  940. AC_SUBST(DL_OBJS)
  941. AC_SUBST(LD_FLAGS)
  942. AC_SUBST(MAKE_LIB)
  943. AC_SUBST(MATH_LIBS)
  944. AC_SUBST(SHLIB_CFLAGS)
  945. AC_SUBST(SHLIB_LD)
  946. AC_SUBST(SHLIB_LD_LIBS)
  947. AC_SUBST(SHLIB_SUFFIX)
  948. AC_SUBST(TCL_BUILD_LIB_SPEC)
  949. AC_SUBST(TCL_LD_SEARCH_FLAGS)
  950. AC_SUBST(TCL_LIB_FILE)
  951. AC_SUBST(TCL_LIB_SPEC)
  952. AC_SUBST(TCL_LIB_VERSIONS_OK)
  953. AC_SUBST(TCL_MAJOR_VERSION)
  954. AC_SUBST(TCL_MINOR_VERSION)
  955. AC_SUBST(TCL_SHARED_LIB_SUFFIX)
  956. AC_SUBST(TCL_SHLIB_CFLAGS)
  957. AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
  958. AC_SUBST(TCL_VERSION)
  959.  
  960. AC_OUTPUT(Makefile tclConfig.sh)
  961.